package com.woniuxy.config;

import com.woniuxy.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;
/**
 * 配置类
 */
//@Configuration
public class CarServiceRentalConfigurer implements WebMvcConfigurer {
    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //创建放行名单
        List<String> whitePaths = new ArrayList<>();
        whitePaths.add("/favicon.ico");  //网站图标
        whitePaths.add("/index.html");  //登录页面
        whitePaths.add("/user/login");   //登录
        whitePaths.add("/js/*");
        whitePaths.add("/css/*");
        whitePaths.add("/element-ui/**");
        whitePaths.add("/img/*");
        //增加拦截器
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")   //拦截所有的地址
                .excludePathPatterns(whitePaths);  //放行白名单
    }
}
